package com.zsw.controller;

import com.zsw.service.AccountService;
import feign.FeignException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author zhangsw
 */
@RestController
@Api("账户服务")
public class AccountController {

    @Resource
    private AccountService accountService;

    @ApiOperation("扣减账户余额")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户id"),
            @ApiImplicitParam(name = "money",value = "扣除的钱")
    })
    @PostMapping(value = "/account/deduct")
    public boolean deductAccountBalance(
            @RequestParam(value = "userId") Integer userId,
            @RequestParam(value = "money")BigDecimal money
            ) throws FeignException {
        return accountService.debit(userId,money);
    }

}
